package annotation;

import java.lang.annotation.Annotation;
import java.util.Arrays;

/**
 * Created by wangyg
 * on 2017/3/23 17:18
 */
public class Utils {

	public static void sout(Class<?> clazz) {
		System.out.println("—————————————————Fields———————————————");
		System.out.println(Arrays.toString(clazz.getFields()));
		System.out.println();
		System.out.println(Arrays.toString(clazz.getDeclaredFields()));
		System.out.println("—————————————————Methods———————————————");
		System.out.println(Arrays.toString(clazz.getMethods()));
		System.out.println();
		System.out.println(Arrays.toString(clazz.getDeclaredMethods()));
		System.out.println("—————————————————Constructor———————————————");
		System.out.println(Arrays.toString(clazz.getConstructors()));
		System.out.println();
		System.out.println(Arrays.toString(clazz.getDeclaredConstructors()));
		System.out.println("—————————————————Annotation———————————————");
		System.out.println(Arrays.toString(clazz.getAnnotations()));
		System.out.println();
		System.out.println(Arrays.toString(clazz.getDeclaredAnnotations()));
		System.out.println(clazz.isAnnotationPresent(App.class));
	}

	public static  void getAnnoMsg  (Class<?> clz,Class<? extends App> clazz) {
		if (clz.isAnnotationPresent(clazz)) {
			App app = clz.getAnnotation(clazz);
			String appName = app.appName();
//			return appName;
			System.out.println(appName);
		}
	}
}
